package com.sino.operation.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sino.operation.Exception.sinoexception.CounterSignException;
import com.sino.operation.commons.response.CenterResponseEnum;
import com.sino.operation.entity.BizAccountmanageInfo;
import com.sino.operation.entity.BizAddImage;
import com.sino.operation.entity.BizTranslist;
import com.sino.operation.mapper.BizAccountmanageInfoMapper;
import com.sino.operation.mapper.BizAddImageMapper;
import com.sino.operation.mapper.BizTranslistMapper;
import com.sino.operation.service.BizAddImageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 账管登记簿表 服务实现类
 * </p>
 *
 * @author admin
 * @since 2021-10-07
 */
@Service
public class BizAddImageServiceImpl extends ServiceImpl<BizAddImageMapper, BizAddImage> implements BizAddImageService {

    @Autowired(required = false)
    private BizAddImageMapper bizAddImageMapper;

    @Autowired(required = false)
    private BizAccountmanageInfoMapper bizAccountmanageInfoMapper;

    @Autowired(required = false)
    private BizTranslistMapper bizTranslistMapper;
    /**
     * @Description: ${柜面柜员签退}
     * param [tellNo]
     * return boolean
     * author 北陈
     * date 2021/10/21 9:50
    */
    @Override
    public Integer counterSignByCenter(String tellNo) {
        Integer taskNum=0;
        QueryWrapper<BizAddImage> bizAddImageQueryWrapper = new QueryWrapper<>();
        Map<String, String> map = new HashMap<>(16);
        map.put("state","W");
        map.put("scan_teller",tellNo);
        bizAddImageQueryWrapper.allEq(map);
        List<BizAddImage> bizAddImages = bizAddImageMapper.selectList(bizAddImageQueryWrapper);

        QueryWrapper<BizAccountmanageInfo> infoQueryWrapper = new QueryWrapper<>();
        HashMap<String, String> hashMap = new HashMap<>(16);
        hashMap.put("sub_transaction_state","1");
        hashMap.put("teller_code",tellNo);
        infoQueryWrapper.allEq(hashMap);
        List<BizAccountmanageInfo> bizAccountmanageInfos = bizAccountmanageInfoMapper.selectList(infoQueryWrapper);

        QueryWrapper<BizTranslist> translistQueryWrapper = new QueryWrapper<>();
        translistQueryWrapper.eq("launch_teller_id",tellNo);
        translistQueryWrapper.in("trans_state",new String[]{"1","2","3","9","R"});
        List<BizTranslist> bizTranslists = bizTranslistMapper.selectList(translistQueryWrapper);

        taskNum=bizAddImages.size()+bizAccountmanageInfos.size()+bizTranslists.size();
        return taskNum;
    }
}
